home *** CD-ROM | disk | FTP | other *** search
/ Network PC / Network PC.iso / amiga utilities / communication / bbs / termv4.6 / extras / source / gtlayout-source.lha / LTP_DrawGroup.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-18  |  7.6 KB  |  310 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1996 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. */
  7.  
  8. #ifndef _GTLAYOUT_GLOBAL_H
  9. #include "gtlayout_global.h"
  10. #endif
  11.  
  12. VOID
  13. LTP_DrawObjectLabel(LayoutHandle *Handle,ObjectNode *Node)
  14. {
  15.     if(Node -> Label)
  16.     {
  17.         LONG Left,Top,GlyphHeight = Handle -> GlyphHeight;
  18.  
  19.         switch(Node -> LabelPlace)
  20.         {
  21.             case PLACE_LEFT:
  22.  
  23.                 Left    = Node -> Left;
  24.                 Top    = Node -> Top + (Node -> Height - GlyphHeight) / 2;
  25.  
  26.                 break;
  27.  
  28.             case PLACE_RIGHT:
  29.  
  30.                 Left    = Node -> Left + Node -> Width + INTERWIDTH + INTERWIDTH + Node -> LabelWidth;
  31.                 Top    = Node -> Top + (Node -> Height - GlyphHeight) / 2;
  32.  
  33.                 break;
  34.  
  35.             case PLACE_ABOVE:
  36.  
  37.                 Left    = Node -> Left + (Node -> Width - Node -> LabelWidth) / 2 + INTERWIDTH + Node -> LabelWidth;
  38.                 Top    = Node -> Top - (GlyphHeight + INTERHEIGHT);
  39.  
  40.                 break;
  41.  
  42.             case PLACE_BELOW:
  43.  
  44.                 Left    = Node -> Left + (Node -> Width - Node -> LabelWidth) / 2 + INTERWIDTH + Node -> LabelWidth;
  45.                 Top    = Node -> Top + Node -> Height + INTERHEIGHT;
  46.  
  47.                 break;
  48.         }
  49.  
  50.         LTP_PrintLabel(Handle,Node,Left,Top);
  51.     }
  52. }
  53.  
  54. VOID
  55. LTP_DrawGroup(LayoutHandle *Handle,ObjectNode *Group)
  56. {
  57.     ObjectNode    *Node;
  58.     LONG         i;
  59.     ULONG         page;
  60.  
  61.     if(Group -> Label || Group -> Special . Group . Frame)
  62.         LTP_DrawGroupLabel(Handle,Group);
  63.  
  64.     SCANPAGE(Group,Node,page)
  65.     {
  66.         switch(Node -> Type)
  67.         {
  68. #ifdef OLD_STYLE_DEFAULT_KEY
  69.             case BUTTON_KIND:
  70.  
  71.                 if(Handle -> ReturnKey == Node)
  72.                     LTP_DrawBevelBox(Handle,Node);
  73.  
  74.                 break;
  75. #endif
  76. #ifdef DO_GAUGE_KIND
  77.             case GAUGE_KIND:
  78.             {
  79.                 LONG Percent = Node -> Current;
  80.  
  81.                 Node -> Current = 0;
  82.  
  83.                 LTP_DrawGauge(Handle,Node,Percent,TRUE);
  84.  
  85.                 break;
  86.             }
  87. #endif
  88.             case PALETTE_KIND:
  89.  
  90.                 if(Node -> Special . Palette . UsePicker)
  91.                     LTP_DrawPalette(Handle,Node);
  92.  
  93.                 break;
  94.  
  95.             case GROUP_KIND:
  96.  
  97.                 if(Node -> Label)
  98.                     LTP_DrawGroupLabel(Handle,Node);
  99.  
  100.                 LTP_DrawGroup(Handle,Node);
  101.  
  102.                 break;
  103.  
  104.             case XBAR_KIND:
  105.             {
  106.                 LONG Top = Node -> Top + ((Node -> Height + 1) / 2) - 1;
  107.                 struct RastPort *RPort = &Handle -> RPort;
  108.  
  109.                 if(Node -> Special . Bar . FullSize)
  110.                 {
  111.                     LTP_SetAPen(RPort,Handle -> ShadowPen);
  112.                     LTP_DrawLine(RPort,Handle -> Window -> BorderLeft,Top,Handle -> Window -> Width - (Handle -> Window -> BorderRight + 1),Top);
  113.  
  114.                     LTP_SetAPen(RPort,Handle -> ShinePen);
  115.                     LTP_DrawLine(RPort,Handle -> Window -> BorderLeft,Top + 1,Handle -> Window -> Width - (Handle -> Window -> BorderRight + 1),Top + 1);
  116.                 }
  117.                 else
  118.                 {
  119.                     LONG Room;
  120.  
  121.                     if(Node -> Special . Bar . Parent -> Label)
  122.                         Room = 2 * Handle -> GlyphWidth;
  123.                     else
  124.                         Room = 0;
  125.  
  126.                     LTP_SetAPen(RPort,Handle -> ShadowPen);
  127.                     LTP_PolyDraw(RPort,3,
  128.                         Node -> Special . Bar . Parent -> Left + Room,Top + 1,
  129.                         Node -> Special . Bar . Parent -> Left + Room,Top,
  130.                         Node -> Special . Bar . Parent -> Left + Node -> Special . Bar . Parent -> Width - 1 - 1 - Room,Top);
  131.  
  132.                     LTP_SetAPen(RPort,Handle -> ShinePen);
  133.                     LTP_PolyDraw(RPort,3,
  134.                         Node -> Special . Bar . Parent -> Left + Room + 1,Top + 1,
  135.                         Node -> Special . Bar . Parent -> Left + Node -> Special . Bar . Parent -> Width - 1 - Room,Top + 1,
  136.                         Node -> Special . Bar . Parent -> Left + Node -> Special . Bar . Parent -> Width - 1 - Room,Top);
  137.                 }
  138.  
  139.                 break;
  140.             }
  141.  
  142.             case YBAR_KIND:
  143.             {
  144.                 LONG Left = Node -> Left + ((Node -> Width + 1) / 2) - 1,Room;
  145.                 struct RastPort *RPort = &Handle -> RPort;
  146.  
  147.                 if(Node -> Special . Bar . Parent -> Label)
  148.                     Room = Handle->GlyphHeight + Handle -> InterHeight;
  149.                 else
  150.                     Room = 0;
  151.  
  152.                 LTP_SetAPen(RPort,Handle -> ShadowPen);
  153.                 LTP_PolyDraw(RPort,3,
  154.                     Left + 1,    Node -> Special . Bar . Parent -> Top + Room,
  155.                     Left,        Node -> Special . Bar . Parent -> Top + Room,
  156.                     Left,        Node -> Special . Bar . Parent -> Top + Node -> Special . Bar . Parent -> Height - 1 - 1 - Room);
  157.  
  158.                 LTP_SetAPen(RPort,Handle -> ShinePen);
  159.                 LTP_PolyDraw(RPort,3,
  160.                     Left + 1,    Node -> Special . Bar . Parent -> Top + Room + 1,
  161.                     Left + 1,    Node -> Special . Bar . Parent -> Top + Node -> Special . Bar . Parent -> Height - 1 - Room,
  162.                     Left,        Node -> Special . Bar . Parent -> Top + Node -> Special . Bar . Parent -> Height - 1 - Room);
  163.  
  164.                 if((Handle->AspectY + Handle->AspectX - 1) / Handle->AspectX >= 2)
  165.                 {
  166.                     LTP_SetAPen(RPort,Handle -> ShadowPen);
  167.                     LTP_DrawLine(RPort,    Left - 1,    Node -> Special . Bar . Parent -> Top + Room,
  168.                                 Left - 1,    Node -> Special . Bar . Parent -> Top + Node -> Special . Bar . Parent -> Height - 1 - Room);
  169.  
  170.                     LTP_SetAPen(RPort,Handle -> ShinePen);
  171.                     LTP_DrawLine(RPort,    Left + 2,    Node -> Special . Bar . Parent -> Top + Room,
  172.                                 Left + 2,    Node -> Special . Bar . Parent -> Top + Node -> Special . Bar . Parent -> Height - 1 - Room);
  173.                 }
  174.  
  175.                 break;
  176.             }
  177.  
  178.             case FRAME_KIND:
  179.  
  180.                 if(Node -> Special . Frame . DrawBox)
  181.                     LTP_DrawBevelBox(Handle,Node);
  182.  
  183.                 if(Node -> Special . Frame . RefreshHook)
  184.                 {
  185.                     RefreshMsg Message;
  186.  
  187.                     Message . ID        = Node -> ID;
  188.                     Message . Left        = Node -> Left;
  189.                     Message . Top        = Node -> Top;
  190.                     Message . Width        = Node -> Width;
  191.                     Message . Height    = Node -> Height;
  192.  
  193.                     if(Node -> Special . Frame . DrawBox)
  194.                     {
  195.                         Message . Left        += 4;
  196.                         Message . Top        += 2;
  197.                         Message . Width        -= 8;
  198.                         Message . Height    -= 4;
  199.                     }
  200.  
  201.                     CallHookPkt(Node -> Special . Frame . RefreshHook,Handle,&Message);
  202.                 }
  203.  
  204.                 // FALL THROUGH TO...
  205.  
  206.             case BOOPSI_KIND:
  207.  
  208.                 // FALL THROUGH TO...
  209.  
  210.             case POPUP_KIND:
  211.  
  212.                 // FALL THROUGH TO...
  213.  
  214.             case TAPEDECK_KIND:
  215.  
  216.                 LTP_DrawObjectLabel(Handle,Node);
  217.                 break;
  218.  
  219.             case MX_KIND:
  220.  
  221.                 if(Node -> Label && !V39)
  222.                     LTP_PrintLabel(Handle,Node,Node -> Left,Node -> Top + (Node -> Height - Handle -> GlyphHeight) / 2 + 1);
  223.  
  224.                 break;
  225.  
  226.             case LISTVIEW_KIND:
  227.             {
  228.                 struct RastPort *RPort = &Handle -> RPort;
  229.  
  230.                 if(Node -> Special . List . ExtraLabels)
  231.                 {
  232.                     LTP_SetPens(RPort,Handle -> TextPen,0,JAM1);
  233.  
  234.                     for(i = 0 ; Node -> Special . List . ExtraLabels[i] ; i++)
  235.                     {
  236.                         LONG Len = strlen(Node -> Special . List . ExtraLabels[i]);
  237.  
  238.                         LTP_PrintText(RPort,Node -> Special . List . ExtraLabels[i],Len,Node -> Left - (TextLength(RPort,Node -> Special . List . ExtraLabels[i],Len) + INTERWIDTH),Node -> Top + 2 + i * Handle->GlyphHeight);
  239.                     }
  240.                 }
  241.  
  242.                 if(Node -> Label)
  243.                 {
  244.                     if(Node -> LabelPlace == PLACE_ABOVE && Node -> Special . List . FlushLabelLeft)
  245.                     {
  246.                         struct TextFont *Font = NULL,*OldFont;
  247.  
  248.                         if(Node -> Special . List . TextAttr)
  249.                         {
  250.                             if(Font = LTP_OpenFont(Node -> Special . List . TextAttr))
  251.                             {
  252.                                 OldFont = RPort->Font;
  253.  
  254.                                 SetFont(RPort,Font);
  255.                             }
  256.                             else
  257.                                 break;
  258.                         }
  259.  
  260.                         LTP_PrintLabel(Handle,Node,Node -> Left + 2 + INTERWIDTH + Node -> LabelWidth,Node -> Top - (Handle->GlyphHeight + INTERHEIGHT));
  261.  
  262.                         if(Font)
  263.                         {
  264.                             SetFont(RPort,OldFont);
  265.  
  266.                             CloseFont(Font);
  267.                         }
  268.                     }
  269.                     else
  270.                     {
  271.                         if(Node -> Special . List . TextAttr)
  272.                             LTP_DrawObjectLabel(Handle,Node);
  273.                     }
  274.                 }
  275.  
  276.                 break;
  277.             }
  278.  
  279.             case BOX_KIND:
  280.             {
  281.                 struct RastPort *RPort = &Handle -> RPort;
  282.  
  283.                 Node -> Special . Box . Parent = Group;
  284.  
  285.                 if(Node -> Special . Box . DrawBox)
  286.                     LTP_DrawBevelBox(Handle,Node);
  287.  
  288.                 LockLayerRom(RPort->Layer);
  289.  
  290.                 for(i = 0 ; i < Node -> Lines ; i++)
  291.                 {
  292.                     if(Node -> Special . Box . Labels && Node -> Special . Box . Labels[i])
  293.                     {
  294.                         LONG Len = strlen(Node -> Special . Box . Labels[i]);
  295.  
  296.                         LTP_SetPens(RPort,Handle -> TextPen,0,JAM1);
  297.                         LTP_PrintText(RPort,Node -> Special . Box . Labels[i],Len,Node -> Left - (TextLength(RPort,Node -> Special . Box . Labels[i],Len) + INTERWIDTH),Node -> Top + 2 + i * Handle->GlyphHeight);
  298.                     }
  299.  
  300.                     LTP_PrintBoxLine(Handle,Node,i);
  301.                 }
  302.  
  303.                 UnlockLayerRom(RPort->Layer);
  304.  
  305.                 break;
  306.             }
  307.         }
  308.     }
  309. }
  310.